-
-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance Readability of DISK READ/DISK WRITE Columns by Shortening Labels and Values #1557
base: main
Are you sure you want to change the base?
Conversation
I also wanted to know when, while changing the total width of " Line 298 in 4102862
This is because I don't know, what this does. please inform me about this, I will try to make the changes accordingly. |
Row.c
Outdated
int len = snprintf(buffer, sizeof(buffer), "%7.2f K/s ", rate / ONE_K); | ||
double rateToPrint = rate / ONE_K; | ||
unsigned char precision = Row_getPrecision (rateToPrint); | ||
int len = snprintf(buffer, sizeof(buffer), "%5.*fK/s ", precision, rateToPrint); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
precision
takes the typeint
. You should set the data type properly.- There is a potential of converting this into a loop. You can see the code of
Meter_humanUnit()
function for how it can be done. There is a globalunitPrefixes
array that you can utilize.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| I don't know, what this does. please inform me about this, I will try to make the changes accordingly.
This (11) sets the default column width if none is specified in the configuration file from memory - if we're changing the default reporting width in Row.c its very likely this pcp code will need to change to match it.
The spacing for Further more, From the display side of things: There's a list of IEC unit prefixes for a reason. Please use that one to avoid code duplication. Also, the space before |
042354a
to
66bdf58
Compare
Row.c:511:13: warning: 6th function call argument is an uninitialized value [core.CallAndMessage]
511 | len = snprintf(buffer, sizeof(buffer), "%c/s ", unitPrefixes[unitPrefixIndex]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/stdio2.h:77:3: note: expanded from macro 'snprintf'
77 | __builtin___snprintf_chk (str, len, __USE_FORTIFY_LEVEL - 1, \
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
78 | __glibc_objsize (str), __VA_ARGS__)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ What is left uninitialized? I am unable to understand. |
Potential reading out of bounds. |
int len = snprintf(buffer, sizeof(buffer), "%7.2f T/s ", rate / ONE_T); | ||
RichString_appendnAscii(str, largeNumberColor, buffer, len); | ||
int len = snprintf(buffer, sizeof(buffer), "%4.0f B/s ", rate); | ||
RichString_appendnAscii(str, shadowColor, buffer, len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why using shadowColor
? Ideally nonzero values should not use that text color -- the visual of that would let users skip that entry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I used it because it was mentioned in the Issue.
#991 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well. I would personally disagree with @BenBE unless these small values would practically make a lot of visual noise. But I am not the one to decide on this (I just put my suggestion).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, the current code shadows values below 1KiB/s. Fine either way IMO, but the note from @Explorer09 regarding accidentally visually skipping small values is valid.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of now, according to the code in the main branch, only values below 0.005 B/s are in shadowColor
.
However, in this pull request, I have made shadowColor
include all values below 1 KiB/s. This change may cause small values to be accidentally skipped visually, especially for existing users. Therefore, I will change it back to the original settings.
Row.c
Outdated
} | ||
} | ||
|
||
int len = snprintf(buffer, sizeof(buffer), "%5.*f", precision, rate); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought you would want "%4.*f"
as the format. That is, one digit less.
Output example A
0 B/s - 9999 B/s
9.77 K/s - 9.99 K/s
10.0 K/s - 99.9 K/s
100 K/s - 9999 K/s
9.77 M/s - 9.99 M/s
...
100 Q/s - 9999 Q/s
infinity
Output example B
0 B/s - 1023 B/s
1.00 K/s - 9.99 K/s
10.0 K/s - 99.9 K/s
100 K/s - 1023 K/s
1.00 M/s - 9.99 M/s
...
100 Q/s - 9999 Q/s
infinity
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we actually want 4 digits.
By using "%5.*f"
, it meant the total width of the output field is 5, including the decimal point and digits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you would get 999.9 K/s
. I bet you didn't test that one out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As its yes for this, should I shift to 4.*f
now, or use 5.*f
.
I am asking this because for 4.*f
I have to change the precision logic and if it stays 5.*f
I have to add a column width, currently its 9 (for any kind of Disk IO rates), it will be then 10.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then you would get
999.9 K/s
. I bet you didn't test that one out.
I wanted to understand, is there any issue with printing 999.9 K/s
? I am unable to get it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For size units we usually just use 3 significant digits as extra precisions are less useful for UI display purpose. Add a decimal point and it becomes 4 characters of width. When the decimal points are not needed, i.e. for numbers in range 100 - 9999, four digits can be shown for the same width, but that's more of a special case.
The numbers jump from one unit to the next in power of 1024, and that was the reason of 3 significant digits.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perfect, I understood why to use 3 significant digits for UI displays. Will now fix this to make 4.*f
.
Thanks.
Should there be space for other values too, like when it is |
I can help answer that. Yes. Because otherwise the numbers can look misaligned, when there is an entire column of the numbers. |
c326af3
to
720c3d0
Compare
I made the rate to Also ran a small independent test to ensure the |
Observations before addressing GitHub issue #991:
The column titles for RCHAR & WCHAR take 6 characters, while the titles for DISK READ, DISK WRITE, and DISK R/W (representing total I/O rate in bytes per second) take 12 characters. This PR reduces them to 9 characters.
Why not make the column titles for DISK operations consistent with RCHAR & WCHAR?
The RCHAR & WCHAR columns use an
unsigned long long
data type, while DISK READ & DISK WRITE usedouble
, which adds an extra character for the decimal point when printing.The DISK READ & DISK WRITE columns represent rates, which include a time dimension, thus requiring 2 additional characters compared to RCHAR & WCHAR.
In total, we need 3 extra characters for DISK READ, DISK WRITE, and DISK R/W compared to RCHAR & WCHAR.
What has this PR changed?
This PR changed the column titles as required and
introduced a dynamic precision variable, adjusting based on the value to be printed. The total number of numerical characters allowed for printing is 4. The precision adjusts as follows:
3.141
.31.41
.314.1
.3141
.